package com.firesafe.common.exception;

import com.firesafe.common.utils.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

//ControllerAdvice包含Component
@ControllerAdvice
@Slf4j
public class GlobalExceptionHandler {
    @ExceptionHandler(RRException.class)
    @ResponseBody
    public R handleRRException(RRException e){
        log.warn("{},{}",e.getCode(),e.getMsg());
        return R.error(e.getCode(),e.getMsg());
    }
}
